fix: spring messaging kotlin async aware instrumentation#11047
fix: spring messaging kotlin async aware instrumentation#11047
Conversation
…consume context to a kotlin suspend consume fun
…ener-instrumentation
4885bba to
8eb2a7f
Compare
8eb2a7f to
7e0822f
Compare
| implements Instrumenter.ForSingleType, Instrumenter.HasMethodAdvice { | ||
|
|
||
| public KotlinAwareHandlerInstrumentation() { | ||
| super("spring-messaging", "spring-messaging-4"); |
There was a problem hiding this comment.
Consider adding an alias that specifically mentions kotlin, such as spring-messaging-kotlin - that would let us disable this specific instrumentation while leaving the main spring-messaging instrumentation enabled.
| @Override | ||
| public List<Instrumenter> typeInstrumentations() { | ||
| return Collections.singletonList(new KotlinAwareHandlerInstrumentation()); | ||
| } | ||
|
|
There was a problem hiding this comment.
Remove this - use the default implementation of typeInstrumentations() which does the same thing
| @Override | |
| public List<Instrumenter> typeInstrumentations() { | |
| return Collections.singletonList(new KotlinAwareHandlerInstrumentation()); | |
| } |
| span.finish(); | ||
| } | ||
| if (null != error) { | ||
| DECORATE.onError(span, error); |
There was a problem hiding this comment.
Isn't this already done above in lines 97-99?
mcculls
left a comment
There was a problem hiding this comment.
Looks reasonable, just a couple of things to clean up before this can be merged
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 59 metrics, 12 unstable metrics. Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.61.0-SNAPSHOT~ca4ac9c8ef, baseline=1.61.0-SNAPSHOT~b664cc0f2a
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.063 s) : 0, 1063392
Total [baseline] (8.857 s) : 0, 8857406
Agent [candidate] (1.056 s) : 0, 1055707
Total [candidate] (8.859 s) : 0, 8859460
section iast
Agent [baseline] (1.23 s) : 0, 1229715
Total [baseline] (9.536 s) : 0, 9535540
Agent [candidate] (1.22 s) : 0, 1220177
Total [candidate] (9.531 s) : 0, 9531402
gantt
title insecure-bank - break down per module: candidate=1.61.0-SNAPSHOT~ca4ac9c8ef, baseline=1.61.0-SNAPSHOT~b664cc0f2a
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.24 ms) : 0, 1240
crashtracking [candidate] (1.216 ms) : 0, 1216
BytebuddyAgent [baseline] (636.741 ms) : 0, 636741
BytebuddyAgent [candidate] (632.233 ms) : 0, 632233
AgentMeter [baseline] (29.803 ms) : 0, 29803
AgentMeter [candidate] (29.198 ms) : 0, 29198
GlobalTracer [baseline] (250.664 ms) : 0, 250664
GlobalTracer [candidate] (248.215 ms) : 0, 248215
AppSec [baseline] (32.577 ms) : 0, 32577
AppSec [candidate] (32.05 ms) : 0, 32050
Debugger [baseline] (59.865 ms) : 0, 59865
Debugger [candidate] (58.992 ms) : 0, 58992
Remote Config [baseline] (604.589 µs) : 0, 605
Remote Config [candidate] (603.096 µs) : 0, 603
Telemetry [baseline] (8.162 ms) : 0, 8162
Telemetry [candidate] (8.137 ms) : 0, 8137
Flare Poller [baseline] (7.491 ms) : 0, 7491
Flare Poller [candidate] (8.862 ms) : 0, 8862
section iast
crashtracking [baseline] (1.239 ms) : 0, 1239
crashtracking [candidate] (1.214 ms) : 0, 1214
BytebuddyAgent [baseline] (805.335 ms) : 0, 805335
BytebuddyAgent [candidate] (799.521 ms) : 0, 799521
AgentMeter [baseline] (11.585 ms) : 0, 11585
AgentMeter [candidate] (11.348 ms) : 0, 11348
GlobalTracer [baseline] (239.962 ms) : 0, 239962
GlobalTracer [candidate] (238.496 ms) : 0, 238496
IAST [baseline] (27.071 ms) : 0, 27071
IAST [candidate] (27.331 ms) : 0, 27331
AppSec [baseline] (31.343 ms) : 0, 31343
AppSec [candidate] (31.444 ms) : 0, 31444
Debugger [baseline] (57.583 ms) : 0, 57583
Debugger [candidate] (60.792 ms) : 0, 60792
Remote Config [baseline] (546.328 µs) : 0, 546
Remote Config [candidate] (575.832 µs) : 0, 576
Telemetry [baseline] (13.973 ms) : 0, 13973
Telemetry [candidate] (9.942 ms) : 0, 9942
Flare Poller [baseline] (4.364 ms) : 0, 4364
Flare Poller [candidate] (3.444 ms) : 0, 3444
Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.61.0-SNAPSHOT~ca4ac9c8ef, baseline=1.61.0-SNAPSHOT~b664cc0f2a
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.06 s) : 0, 1059520
Total [baseline] (11.131 s) : 0, 11130915
Agent [candidate] (1.059 s) : 0, 1059221
Total [candidate] (11.094 s) : 0, 11093552
section appsec
Agent [baseline] (1.252 s) : 0, 1251939
Total [baseline] (11.128 s) : 0, 11128308
Agent [candidate] (1.246 s) : 0, 1246075
Total [candidate] (11.061 s) : 0, 11060727
section iast
Agent [baseline] (1.225 s) : 0, 1225140
Total [baseline] (11.308 s) : 0, 11308118
Agent [candidate] (1.241 s) : 0, 1240694
Total [candidate] (11.328 s) : 0, 11327515
section profiling
Agent [baseline] (1.182 s) : 0, 1182495
Total [baseline] (11.088 s) : 0, 11087978
Agent [candidate] (1.18 s) : 0, 1180494
Total [candidate] (11.205 s) : 0, 11204796
gantt
title petclinic - break down per module: candidate=1.61.0-SNAPSHOT~ca4ac9c8ef, baseline=1.61.0-SNAPSHOT~b664cc0f2a
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.239 ms) : 0, 1239
crashtracking [candidate] (1.24 ms) : 0, 1240
BytebuddyAgent [baseline] (634.903 ms) : 0, 634903
BytebuddyAgent [candidate] (635.413 ms) : 0, 635413
AgentMeter [baseline] (29.552 ms) : 0, 29552
AgentMeter [candidate] (29.329 ms) : 0, 29329
GlobalTracer [baseline] (249.023 ms) : 0, 249023
GlobalTracer [candidate] (248.003 ms) : 0, 248003
AppSec [baseline] (31.929 ms) : 0, 31929
AppSec [candidate] (32.012 ms) : 0, 32012
Debugger [baseline] (59.73 ms) : 0, 59730
Debugger [candidate] (59.994 ms) : 0, 59994
Remote Config [baseline] (616.969 µs) : 0, 617
Remote Config [candidate] (664.27 µs) : 0, 664
Telemetry [baseline] (8.088 ms) : 0, 8088
Telemetry [candidate] (8.078 ms) : 0, 8078
Flare Poller [baseline] (8.206 ms) : 0, 8206
Flare Poller [candidate] (8.21 ms) : 0, 8210
section appsec
crashtracking [baseline] (1.233 ms) : 0, 1233
crashtracking [candidate] (1.212 ms) : 0, 1212
BytebuddyAgent [baseline] (663.134 ms) : 0, 663134
BytebuddyAgent [candidate] (661.052 ms) : 0, 661052
AgentMeter [baseline] (12.174 ms) : 0, 12174
AgentMeter [candidate] (12.05 ms) : 0, 12050
GlobalTracer [baseline] (250.223 ms) : 0, 250223
GlobalTracer [candidate] (248.301 ms) : 0, 248301
IAST [baseline] (24.768 ms) : 0, 24768
IAST [candidate] (24.44 ms) : 0, 24440
AppSec [baseline] (184.809 ms) : 0, 184809
AppSec [candidate] (183.931 ms) : 0, 183931
Debugger [baseline] (66.243 ms) : 0, 66243
Debugger [candidate] (66.09 ms) : 0, 66090
Remote Config [baseline] (605.379 µs) : 0, 605
Remote Config [candidate] (597.619 µs) : 0, 598
Telemetry [baseline] (8.755 ms) : 0, 8755
Telemetry [candidate] (8.585 ms) : 0, 8585
Flare Poller [baseline] (3.586 ms) : 0, 3586
Flare Poller [candidate] (3.521 ms) : 0, 3521
section iast
crashtracking [baseline] (1.229 ms) : 0, 1229
crashtracking [candidate] (1.249 ms) : 0, 1249
BytebuddyAgent [baseline] (802.673 ms) : 0, 802673
BytebuddyAgent [candidate] (813.384 ms) : 0, 813384
AgentMeter [baseline] (11.372 ms) : 0, 11372
AgentMeter [candidate] (11.624 ms) : 0, 11624
GlobalTracer [baseline] (238.642 ms) : 0, 238642
GlobalTracer [candidate] (241.261 ms) : 0, 241261
IAST [baseline] (25.75 ms) : 0, 25750
IAST [candidate] (26.171 ms) : 0, 26171
AppSec [baseline] (31.189 ms) : 0, 31189
AppSec [candidate] (30.672 ms) : 0, 30672
Debugger [baseline] (58.787 ms) : 0, 58787
Debugger [candidate] (63.725 ms) : 0, 63725
Remote Config [baseline] (526.625 µs) : 0, 527
Remote Config [candidate] (538.209 µs) : 0, 538
Telemetry [baseline] (13.793 ms) : 0, 13793
Telemetry [candidate] (11.83 ms) : 0, 11830
Flare Poller [baseline] (4.955 ms) : 0, 4955
Flare Poller [candidate] (3.677 ms) : 0, 3677
section profiling
crashtracking [baseline] (1.189 ms) : 0, 1189
crashtracking [candidate] (1.165 ms) : 0, 1165
BytebuddyAgent [baseline] (690.365 ms) : 0, 690365
BytebuddyAgent [candidate] (689.514 ms) : 0, 689514
AgentMeter [baseline] (9.089 ms) : 0, 9089
AgentMeter [candidate] (9.055 ms) : 0, 9055
GlobalTracer [baseline] (206.631 ms) : 0, 206631
GlobalTracer [candidate] (206.259 ms) : 0, 206259
AppSec [baseline] (32.456 ms) : 0, 32456
AppSec [candidate] (32.475 ms) : 0, 32475
Debugger [baseline] (65.631 ms) : 0, 65631
Debugger [candidate] (65.496 ms) : 0, 65496
Remote Config [baseline] (560.437 µs) : 0, 560
Remote Config [candidate] (560.819 µs) : 0, 561
Telemetry [baseline] (7.876 ms) : 0, 7876
Telemetry [candidate] (7.853 ms) : 0, 7853
Flare Poller [baseline] (3.547 ms) : 0, 3547
Flare Poller [candidate] (3.57 ms) : 0, 3570
ProfilingAgent [baseline] (94.001 ms) : 0, 94001
ProfilingAgent [candidate] (93.554 ms) : 0, 93554
Profiling [baseline] (94.573 ms) : 0, 94573
Profiling [candidate] (94.134 ms) : 0, 94134
LoadParameters
See matching parameters
SummaryFound 1 performance improvements and 0 performance regressions! Performance is the same for 17 metrics, 18 unstable metrics.
Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.61.0-SNAPSHOT~ca4ac9c8ef, baseline=1.61.0-SNAPSHOT~b664cc0f2a
dateFormat X
axisFormat %s
section baseline
no_agent (1.256 ms) : 1244, 1268
. : milestone, 1256,
iast (3.346 ms) : 3295, 3397
. : milestone, 3346,
iast_FULL (6.116 ms) : 6053, 6179
. : milestone, 6116,
iast_GLOBAL (3.743 ms) : 3683, 3804
. : milestone, 3743,
profiling (2.507 ms) : 2482, 2531
. : milestone, 2507,
tracing (1.874 ms) : 1859, 1889
. : milestone, 1874,
section candidate
no_agent (1.227 ms) : 1216, 1238
. : milestone, 1227,
iast (3.259 ms) : 3212, 3306
. : milestone, 3259,
iast_FULL (6.051 ms) : 5989, 6113
. : milestone, 6051,
iast_GLOBAL (3.724 ms) : 3662, 3786
. : milestone, 3724,
profiling (2.336 ms) : 2311, 2361
. : milestone, 2336,
tracing (1.87 ms) : 1855, 1885
. : milestone, 1870,
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.61.0-SNAPSHOT~ca4ac9c8ef, baseline=1.61.0-SNAPSHOT~b664cc0f2a
dateFormat X
axisFormat %s
section baseline
no_agent (18.302 ms) : 18112, 18492
. : milestone, 18302,
appsec (18.636 ms) : 18446, 18825
. : milestone, 18636,
code_origins (17.787 ms) : 17612, 17962
. : milestone, 17787,
iast (18.038 ms) : 17857, 18220
. : milestone, 18038,
profiling (20.396 ms) : 20183, 20608
. : milestone, 20396,
tracing (17.603 ms) : 17431, 17775
. : milestone, 17603,
section candidate
no_agent (18.498 ms) : 18314, 18683
. : milestone, 18498,
appsec (18.581 ms) : 18395, 18767
. : milestone, 18581,
code_origins (18.008 ms) : 17829, 18188
. : milestone, 18008,
iast (18.616 ms) : 18431, 18801
. : milestone, 18616,
profiling (19.11 ms) : 18915, 19306
. : milestone, 19110,
tracing (17.697 ms) : 17525, 17870
. : milestone, 17697,
DacapoParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 11 metrics, 1 unstable metrics. Execution time for tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.61.0-SNAPSHOT~ca4ac9c8ef, baseline=1.61.0-SNAPSHOT~b664cc0f2a
dateFormat X
axisFormat %s
section baseline
no_agent (1.502 ms) : 1491, 1514
. : milestone, 1502,
appsec (2.551 ms) : 2496, 2607
. : milestone, 2551,
iast (2.294 ms) : 2224, 2364
. : milestone, 2294,
iast_GLOBAL (2.318 ms) : 2249, 2388
. : milestone, 2318,
profiling (2.106 ms) : 2051, 2162
. : milestone, 2106,
tracing (2.093 ms) : 2039, 2147
. : milestone, 2093,
section candidate
no_agent (1.493 ms) : 1481, 1504
. : milestone, 1493,
appsec (3.826 ms) : 3601, 4052
. : milestone, 3826,
iast (2.286 ms) : 2217, 2356
. : milestone, 2286,
iast_GLOBAL (2.33 ms) : 2259, 2400
. : milestone, 2330,
profiling (2.141 ms) : 2083, 2199
. : milestone, 2141,
tracing (2.09 ms) : 2036, 2144
. : milestone, 2090,
Execution time for biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.61.0-SNAPSHOT~ca4ac9c8ef, baseline=1.61.0-SNAPSHOT~b664cc0f2a
dateFormat X
axisFormat %s
section baseline
no_agent (15.104 s) : 15104000, 15104000
. : milestone, 15104000,
appsec (15.031 s) : 15031000, 15031000
. : milestone, 15031000,
iast (18.516 s) : 18516000, 18516000
. : milestone, 18516000,
iast_GLOBAL (17.722 s) : 17722000, 17722000
. : milestone, 17722000,
profiling (14.915 s) : 14915000, 14915000
. : milestone, 14915000,
tracing (14.812 s) : 14812000, 14812000
. : milestone, 14812000,
section candidate
no_agent (15.551 s) : 15551000, 15551000
. : milestone, 15551000,
appsec (14.614 s) : 14614000, 14614000
. : milestone, 14614000,
iast (18.306 s) : 18306000, 18306000
. : milestone, 18306000,
iast_GLOBAL (17.936 s) : 17936000, 17936000
. : milestone, 17936000,
profiling (15.017 s) : 15017000, 15017000
. : milestone, 15017000,
tracing (15.056 s) : 15056000, 15056000
. : milestone, 15056000,
|
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in Use ⏳ Processing |
What Does This Do
Adds support for
KotlinAwareInvocableHandlerMethodto pass thespring.consumecontext to a kotlin suspend consume fun and keep the span open for entire async execution.Motivation
A kotlin suspend function execution isn't in scope of the spring.consume.
Additional Notes
Reuse slightly refactored
AsyncResultExtensionsclass to provide a unified way of supporting different asynchronous results.Supersedes: #10831 to keep the span open for entire async execution
Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issueJira ticket: APMS-18839
Note: Once your PR is ready to merge, add it to the merge queue by commenting
/merge./merge -ccancels the queue request./merge -f --reason "reason"skips all merge queue checks; please use this judiciously, as some checks do not run at the PR-level. For more information, see this doc.